use super::{SysResult, Syscall};

impl Syscall<'_> {
    pub fn sys_print(&mut self, str_addr: usize, str_len: usize) -> SysResult {
        let buf = unsafe { core::slice::from_raw_parts(str_addr as *const u8, str_len) };
        let str = core::str::from_utf8(buf);
        if let Ok(str) = str {
            crate::serial_print!("{}", str);
        } else {
            error!("Cannot print str");
        }

        Ok(str_len)
    }
}
